package com.lanqiao.javaparkinglot.controller;

import com.lanqiao.javaparkinglot.common.CommonResult;
import com.lanqiao.javaparkinglot.entity.Userlogin;
import com.lanqiao.javaparkinglot.service.UserloginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController

public class UserloginController {
    @Autowired
    UserloginService userloginService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)

    @ResponseBody
public CommonResult Login (@RequestBody Userlogin userlogin){
     Userlogin userlogin1  =userloginService.Login(userlogin.getUsername());
    if(userlogin1==null) {
        return CommonResult.failure("用户名不存在");
    }
    if(!userlogin1.getPassword().equals(userlogin1.getPassword())){
        return CommonResult.failure("密码不正确");
    }
    return CommonResult.success("登录成功",userlogin);
    }


}
